home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #4 / Amiga Plus CD - 2000 - No. 4.iso / Tools / Grafik / Misc / ImageEnginer / ARexx / Batch / Scale.ieb < prev    next >
Encoding:
Text File  |  1997-02-02  |  3.4 KB  |  138 lines

  1. /*
  2. ** $VER: Scale.ieb 1.2, IE Arexx script
  3. ** Image Engineer Batch Processing script
  4. ** Copyright © by Patrik M Nydensten
  5. ** 2/2 1997 Stockholm/Sweden
  6. **
  7. ** Scale image to new size using absolute values.
  8. */
  9.  
  10. options results
  11. signal on error
  12.  
  13. parse arg input command
  14. input = upper(strip(input))
  15. address 'IMAGEENGINEER'
  16.  
  17. select  /* Required batch script commands */
  18.   when input = 'INFO' then    return get_info()
  19.   when input = 'CONFIG' then  return get_config(command)
  20.   when input = 'PROCESS' then return process_image(command)
  21.   otherwise do
  22.     'REQUEST' '"Failure in call to batch script!"' '" Quit "'
  23.     return '<ERROR>'
  24.   end
  25. end
  26.  
  27. exit 0
  28.  
  29. /* Required "Get_info" procedure  ------------------------------------ */
  30. /* S = SECONDARY, A = ALPHA, 1 = Single file, 2 = Multiple files       */
  31.  
  32. get_info:
  33.   back = 'OK'
  34. return back
  35.  
  36. /* Required "Get_config" procedure  ---------------------------------- */
  37.  
  38. get_config:
  39.   parse arg '"'command'"'
  40.  
  41.   NewWidth=320 ; NewHeight=256
  42.  
  43.   if command ~= '' then parse var command NewWidth NewHeight '#'CropQ '#'CalcType .
  44.  
  45.   'IE_TO_FRONT'
  46.  
  47.   form = 'FORM "Scale" " OK | Cancel "',
  48.   ' INTEGER,"New width (X)",2,4096,'NewWidth',SLIDER',
  49.   ' INTEGER,"New height (Y)",2,4096,'NewHeight',SLIDER'
  50.  
  51.   if command = '' then do
  52.     form = form||' CHECKBOX,"Crop image to original size?",0',
  53.     ' CYCLE,"Type:","Best|Fast",0'
  54.  
  55.     form
  56.     parse var result ok NewWidth NewHeight CropQ CalcType .
  57.     if ok = 0 then return '<ERROR>'
  58.  
  59.     if CalcType=0 then CalcType='BEST'
  60.     else CalcType = 'FAST'
  61.   end
  62.   else do
  63.     form
  64.     parse var result ok NewWidth NewHeight .
  65.     if ok = 0 then return '<ERROR>'
  66.  
  67.     CropQ = 'none'
  68.     CalcType = 'none'
  69.   end
  70.  
  71.   back = NewWidth NewHeight '#'CropQ '#'CalcType
  72. return back
  73.  
  74. /* Required "Process_image" procedure  ------------------------------- */
  75.  
  76. process_image:
  77.   parse arg '"'src_image'"' '"'dst_image'"' '"'options'"'
  78.   parse var options NewWidth NewHeight '#'CropQ '#'CalcType .
  79.  
  80.   'OPEN' '"'src_image'"' '24'
  81.   if (RC ~= 0) then do
  82.     'IE_TO_FRONT'
  83.     'REQUEST' '"Failed to load image:' d2c(10)||src_image'"' '" OK "'
  84.     return '<ERROR>'
  85.   end
  86.   else LoadImage = result
  87.  
  88.   if CropQ = 1 then do
  89.     'PROJECT_INFO' LoadImage 'WIDTH'
  90.     IW = Result
  91.     'PROJECT_INFO' LoadImage 'HEIGHT'
  92.     IH = Result
  93.   end
  94.  
  95.   'SCALE' LoadImage NewWidth NewHeight CalcType
  96.   OutputImage = result
  97.   'CLOSE' LoadImage
  98.  
  99.   if CropQ = 1 then do
  100.     'RESIZE' OutputImage IW IH 'CENTER'
  101.     NewImage = result
  102.     'CLOSE' OutputImage
  103.     OutputImage = NewImage
  104.   end
  105.  
  106.   if getclip('cfg_save_frmt')='' then setclip('cfg_save_frmt','ILBM CmpByteRun1')
  107.   'SAVE_DATA' OutputImage '"'dst_image'"' '"'getclip('cfg_save_frmt')'"'
  108.   if (RC ~= 0) then do
  109.     'IE_TO_FRONT'
  110.     'REQUEST' '"Failed to save image:' d2c(10)||dst_image'"' '" OK "'
  111.     return '<ERROR>'
  112.   end
  113.   'CLOSE' OutputImage
  114.  
  115.   back = 'OK'
  116. return back
  117.  
  118. /* Internal procedures  ---------------------------------------------- */
  119.  
  120. /*******************************************************************/
  121. /* This is where control goes when an error code is returned by IE */
  122. /* It puts up a message saying what happened and on which line     */
  123. /*******************************************************************/
  124.  
  125. error:
  126. if RC=5 then do
  127.     IE_TO_FRONT
  128.     LAST_ERROR
  129.     'REQUEST "'||RESULT||'"'
  130. end
  131. else do
  132.     IE_TO_FRONT
  133.     LAST_ERROR
  134.     'REQUEST "Error detected!!!'||D2C(10)||'Image Engineer error message is as follows'||D2C(10)||result||D2C(10)||'Script failed on line '||SIGL||'"' 'Doh!'
  135. end
  136.  
  137. return '<ERROR>'
  138.